<template>
  <div>
    <a-table
      class="antableClass"
      ref="table"
      size="middle"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      @change="handleTableChange"
    >
      <template v-slot:action="text, record">
        <a @click="handleEdit(record, '编辑疑点')">编辑</a>
        <a-divider type="vertical" />
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
          <a>删除</a>
        </a-popconfirm>
      </template>
    </a-table>
    <!-- props: ['id', 'bsjdwName', 'bsjdw', 'protype', 'type'], -->
    <CheckAndEditModel ref="modalForm" @ok="loadData()" />
  </div>
</template>

<script>
import { httpAction, getAction, deleteAction } from '@/api/manage'
import columns from './indexColumns'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CheckAndEditModel from '../../../../sjxmzygl/commView/sssj/sjdg/CheckAndEditModel.vue'
export default {
  name: 'sjdg',
  mixins: [JeecgListMixin],
  components: { CheckAndEditModel },
  props: ['id', 'queryParamId'],
  watch: {
    queryParamId(val) {
        console.log(val);
        this.queryParam.modelId = val
        this.loadData(1)
    },
  },
  data() {
    return {
      columns: columns(this),
      disableMixinCreated: true,
      queryParam:{
        id:'',
        modelId:undefined
      },
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + '-' + range[1] + ' 共' + total + '条'
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0,
      },
      data: [],
      currentRecord: {},
      url: {
        list: '/sjmx/quickDraftResult/queryResultListByQuickId',
        delete: '/sjxmzygl/sjWorkZtfaEveDigao/remove',
      },
    }
  },
  mounted() {
    this.queryParam.id = this.id
    this.loadData(1)
  },
  methods: {
    handleEdit: function (record, name) {
      this.currentRecord = Object.assign({}, record)
      this.$refs.modalForm.edit(record)
      this.$refs.modalForm.title = name
      this.$refs.modalForm.isCheck = false
      this.$refs.modalForm.disableSubmit = false
    },
    handleDelete: function (id) {
      if (!this.url.delete) {
        this.$message.error('请设置url.delete属性!')
        return
      }
      var that = this
      deleteAction(that.url.delete, { id: id }).then((res) => {
        if (res.success) {
          // 重新计算分页问题
          that.$message.success(res.message)
          this.loadData(1)
        } else {
          that.$message.warning(res.message)
        }
      })
    },
  },
}
</script>

<style lang="less" scoped>
@import '~@assets/less/tableTheme.less';
/deep/ .ant-table-thead {
  tr {
    th {
      text-align: center !important;
    }
  }
}
</style>